import { useState, useImperativeHandle, forwardRef } from "react"
//  react 19版本直接获取ref 通过props
const ChildrenA: React.FC<{ count: number , addCount: () => void }> = forwardRef((({ count, addCount }, ref) => {
  const [value, setValue] = useState(1);
  useImperativeHandle(ref, () => {
    return {
      setValue
    }
  })
  return (  
    <div>
      <h2>ChildrenA</h2>
      <h3>App count: { count }</h3>
      <button onClick={() => addCount() }>+1</button>
      <h3>ChildrenA value: { value }</h3>
    </div>
  )
}))



export default ChildrenA